<?php
function GetUserTypeName($id)
{
$sql = mysql_query('SELECT * FROM user_groups where user_groups_id="'.trim($id).'"');
$result = mysql_fetch_row($sql);
$usertypename = $result[1]; 
return $usertypename;
}


function GetLaptopReplacementGrid($id)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.laptopmodel,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where usr.user_no="'.trim($id).'" and lpt.status="approve" ORDER BY  usr.user_no  Asc');



if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Remark</b></th>
						<th><b>Replace</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><textarea name="laptopremarks_'.$result['laptop_id'].'" id="laptopremarks_'.$result['laptop_id'].'" rows="1" cols="15"></textarea></td>
						<td align="center"><input type="checkbox" id="laptop_'.$result['laptop_id'].'" name="laptop_'.$result['laptop_id'].'" value="1"></td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}



function GetAccesoriesReplacementGrid($id)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.company_name,acs.dispatch_location,acs.accessories_id FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where usr.user_no="'.trim($id).'" and acs.status="approve" ORDER BY usr.user_no Asc');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Data Card</b></th>
						<th><b>Dispatch Location</b></th>						
						<th><b>Remark</b></th>
						<th><b>Replace</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>											
						<td align="center"><textarea name="accessoriesremarks_'.$result['accessories_id'].'" id="accessoriesremarks_'.$result['accessories_id'].'" rows="1" cols="15"></textarea></td>
						<td align="center"><input type="checkbox" id="accessories_'.$result['accessories_id'].'" value="1" name="accessories_'.$result['accessories_id'].'"></td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}











function GetRequestedLaptopGrid()
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_designation,usr.user_lastname,usr.user_designation,usr.user_id,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where lpt.status!="approve" and lpt.status!="disapprove" ORDER BY  usr.user_no  Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Model Name</b></th>
						<th><b>Serial No</b></th>
						<th><b>Region</b></th>						
						<th><b>Dispatch From Location</b></th>
						<th><b>Dispatch To Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Approved</b></th>
						<th><b>Not Approved</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

/*
                        if($result['user_designation']=='MT')
						{
						$lapModel = GetLaptopModelNameMT($result['laptopmodel']);
						}
						else
						{
				        $lapModel = GetLaptopModelName($result['laptopmodel']);
						}
						
*/
//$laptopModel = str_replace(" ","",$result['laptopmodel']);

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'. $result['laptopmodel'].'</td>
						<td align="center">'. $result['serial_no']	.'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">

						
    					<input type="checkbox" id="approved_'.$result['laptop_id'].'_'.$result['user_id'].'" name="approved_'.$result['laptop_id'].'_'.$result['user_id'].'" value="1"></td>
  <td align="center"><img src="images/but_delete.gif"  style="cursor:pointer;" onclick=Disapprove("'.trim($result['laptop_id']).'","'.$result['user_id'].'")></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetRequestedAccessoriesGrid()
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,acs.accessories_name,acs.card_no,acs.company_name,acs.division,acs.region,acs.depot_location,acs.dispatch_location,acs.accessories_id,acs.message  FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.status!="approve" and acs.status!="disapprove" ORDER BY acs.accessories_name Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card No</b></th>
						<th><b>Company Name</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Message</b></th>						
						<th><b>Approved</b></th>
						<th><b>Not Approved</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center">'.$result['message'].'</td>											
						<td align="center">
						<input type="checkbox" id="approved_'.$result['accessories_id'].'_'.$result['user_id'].'" name="approved_'.$result['accessories_id'].'_'.$result['user_id'].'" value="1"></td>					    <td align="center"><img src="images/but_delete.gif"  style="cursor:pointer;" onclick=DisapproveAcc('.$result['accessories_id'].','.$result['user_id'].',\''.trim($result['depot_location']).'\')></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetApprovedLaptopGrid($value)
{
	if(!isset($_SESSION['user_name']) || $_SESSION['user_groups_id']!="7" && $_SESSION['user_groups_id']!="6")
	{
$sql = mysql_query('SELECT usr.user_no, usr.user_firstname, usr.user_lastname,usr.user_name,usr.user_id, lpt.division, lpt.laptopmodel, lpt.region, lpt.depot_location, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id FROM users AS usr INNER JOIN laptop AS lpt ON usr.user_id = lpt.user_id WHERE lpt.status = "approve" AND lpt.assigned = "0" AND lpt.depot_location like upper("'.$value.'%") ORDER BY usr.user_no ASC');
	}
	else
	{
		$sql = mysql_query('SELECT usr.user_no, usr.user_firstname, usr.user_lastname,usr.user_name,usr.user_id, lpt.division, lpt.laptopmodel, lpt.region, lpt.depot_location, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id FROM users AS usr INNER JOIN laptop AS lpt ON usr.user_id = lpt.user_id WHERE lpt.status = "approve" AND lpt.assigned = "0" ORDER BY usr.user_no ASC');
	}
if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Region</b></th>
						<th><b>Disptach From Location</b></th>
						<th><b>Dispatch To Location</b></th>
						<th><b>Deliver on</b></th>					
						<th><b>Dispatch</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){


//if(in_array($value, explode('Array',GetLaptopDepotName($result['laptopmodel']))))
//{
$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><input type="checkbox" id="assigned_'.$result['laptop_id'].'_'.$result['user_id'].'" name="assigned_'.$result['laptop_id'].'_'.$result['user_id'].'" value="1"></td>
						</tr>';
						
//}
}
$data .= '</table>';

}

else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetApprovedAccessoriesGrid($value)
{
	if(!isset($_SESSION['user_name']) || $_SESSION['user_groups_id']!="7" && $_SESSION['user_groups_id']!="6")
	{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,acs.accessories_name,acs.card_no,acs.company_name,acs.division,acs.region,acs.depot_location,acs.dispatch_location,acs.accessories_id  FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.status="approve" and acs.assigned="0" and acs.depot_location like upper("'.$value.'%") ORDER BY acs.accessories_name Asc');
	}
	else
	{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,acs.accessories_name,acs.card_no,acs.company_name,acs.division,acs.region,acs.depot_location,acs.dispatch_location,acs.accessories_id  FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.status="approve" and acs.assigned="0" ORDER BY acs.accessories_name Asc');

	}
if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Data Card</b></th>
						<th><b>Company</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>						
						<th><b>Assigned</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['card_no'].'</td>
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center"><input type="checkbox" id="assigned_'.$result['accessories_id'].'_'.$result['user_id'].'_'.$result['depot_location'].'" name="assigned_'.$result['accessories_id'].'_'.$result['user_id'].'_'.$result['depot_location'].'" value="1"></td>					   
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}








function GetDispatchedLaptopGrid($value)
{
	if(!isset($_SESSION['user_name']) || $_SESSION['user_groups_id']!="7" && $_SESSION['user_groups_id']!="6")
	{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.recived FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where lpt.assigned="1" and lpt.dispatch!="1" AND lpt.dispatch_location like upper("'.$value.'%") ORDER BY usr.user_no  Asc');
	}
	else
	{
		$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.recived FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where lpt.assigned="1" and lpt.dispatch!="1" ORDER BY usr.user_no  Asc');
	}

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Region</b></th>
						<th><b>Dispatch From Location</b></th>
						<th><b>Dispatch To Location</b></th>
						<th><b>Dispatch Date</b></th>		
						<th><b>Recieved</b></th>			
						<th><b>Delivered</b></th>
    					<th><b>Upload Receipt</b></td>
						<th><b>Print Report</b></td>
					</tr>';
while($result = mysql_fetch_array($sql)){


if($result['recived']=="0")
{
$disabled = "disabled";
$checked = "";
}
else
{
$disabled = "";
$checked = "checked";
$disabled_checked="disabled";
}

$user_id=$result['user_id'];
$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><input type="checkbox" id="recived_'.$result['laptop_id'].'recived_'.$result['user_id'].'" '.$checked.'   name="recived_'.$result['laptop_id'].'recived_'.$result['user_id'].'" value="1"></td>
						<td align="center"><input type="checkbox" id="assigned_'.$result['laptop_id'].'" '.$disabled.' name="assigned_'.$result['laptop_id'].'" value="1"></td>
						<td align="center"><input type="file" name="userfile_'.$result['laptop_id'].'userfile_'.$result['user_id'].'" '.$disabled.'  id="userfile_'.$result['laptop_id'].'userfile_'.$result['user_id'].'" size="10"/></td>
						<td align="center"><a href="receipt.php?user_id='.$result['user_id'].'">Print receipt</a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}






function GetDispatchedAccessoriesGrid($value)
{
	if(!isset($_SESSION['user_name']) || $_SESSION['user_groups_id']!="7" && $_SESSION['user_groups_id']!="6")
	{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,acs.accessories_name,acs.company_name,acs.division,acs.region,acs.depot_location,acs.dispatch_location,acs.accessories_id,acs.received FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.dispatch!="1" and acs.assigned="1" and acs.dispatch_location like upper("'.$value.'%") ORDER BY usr.user_no Asc');
	}
	else
	{
		$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_id,acs.accessories_name,acs.company_name,acs.division,acs.region,acs.depot_location,acs.dispatch_location,acs.accessories_id,acs.received FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where acs.dispatch!="1" and acs.assigned="1" ORDER BY usr.user_no Asc');
	}
if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Company Name</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Recieved</b></th>										
						<th><b>Delivered</b></th>
    					<th><b>Upload Receipt</b></td>
						</tr>';
while($result = mysql_fetch_array($sql)){

if($result['received']=="0")
{
$disabled = "disabled";
$checked = "";
}
else
{
$disabled = "";
$checked = "checked";
}

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>
						<td align="center"><input type="checkbox" id="received_'.$result['accessories_id'].'received_'.$result['user_id'].'"  '.$checked.' name="received_'.$result['accessories_id'].'received_'.$result['user_id'].'" value="1"></td>						
						<td align="center"><input type="checkbox" id="assigned_'.$result['accessories_id'].'" '.$disabled.' name="assigned_'.$result['accessories_id'].'" value="1"></td>
						<td align="center"><input type="file" name="userfile_'.$result['accessories_id'].'userfile_'.$result['user_id'].'" '.$disabled.' id="userfile'.$result['accessories_id'].'userfile_'.$result['user_id'].'" size="10"/></td>
						   
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}





function GetAccesoriesReturnGrid($id)
{

$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.card_no,acs.company_name,acs.depot_location,acs.dispatch_location,acs.accessories_id,acs.user_id FROM users as usr INNER JOIN accessories as acs ON  usr.user_id = acs.user_id where usr.user_no="'.trim($id).'" and acs.returned="0"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card No</b></th>
						<th><b>Company Name</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Dispatch Location</b></th>						
						<th><b>Remark</b></th>
						<th><b>Returned</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>					
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>											
						<td align="center"><textarea name="accessoriesremarks[]" id="accessoriesremarks[]" rows="1" cols="15"></textarea></td>
						<td align="center">
						<input type="hidden" value="'.$result['user_id'].'" name="acc_user_id[]" id="acc_user_id[]">
					<input type="hidden" value="'.$result['accessories_id'].'" name="accessories_id[]" id="accessories_id[]">										
					<select name="acc[]" id="acc[]">
					<option value="Return" selected="selected">Return</option>
					<option value="Home">Taken Home</option>
					<option value="Lost">Lost/Stolen</option>
					<option value="Damage">Damaged</option>
					</select>
					</td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}





function GetLaptopReturnGrid($id)
{
$sql = mysql_query('SELECT usr.user_id,usr.user_no, usr.user_firstname, usr.user_lastname, lpt.division, lpt.laptopmodel, lpt.serial_no, lpt.region, lpt.depot_location, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id, lpt.serial_no
FROM users AS usr INNER JOIN laptop AS lpt ON usr.user_id = lpt.user_id INNER JOIN laptop_details AS lptd ON lpt.laptop_id = lptd.laptop_id
WHERE usr.user_no = "'.trim($id).'" AND lpt.dispatch = "1" AND lpt.returned = "0" AND lptd.laptop_type = "O"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No.</b></th>						
						<th><b>Region</b></th>
						<th><b>Dispatch From Location</b></th>
						<th><b>Dispatch To Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Remark</b></th>
						<th><b>Select Type</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>						
						<td align="center">'.$result['region'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
	<td align="center"><textarea name="laptopremarks" id="laptopremarks" rows="1" cols="15"></textarea></td>
	
<td align="center">
<input type="hidden" value="'.$result['laptop_id'].'" name="laptop_id">
<input type="hidden" value="'.$result['laptopmodel'].'" name="laptop_model">
<input type="hidden" value="'.$result['serial_no'].'" name="serial_no">
<input type="hidden" value="'.$result['dispatch_location'].'" name="dispatch_location">
<input type="hidden" value="'.$result['user_id'].'" name="user">


<select name="type" id="type">
<option value="Return" selected="selected">Return</option>
<option value="TakenHome">Retained(Taken home)</option>
<option value="Lost">Lost/Stolen</option>
<option value="Damage">Damaged</option>
</select>
</td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetLaptopAccReturnGrid($id)
{
$sql = mysql_query('select la.acc_name,lad.user_id,la.acc_id from laptop_acc la INNER JOIN laptop_acc_details as lad INNER JOIN users as usr ON la.acc_id=lad.accessories_id and usr.user_id=lad.user_id where usr.user_no="'.trim($id).'" and lad.returned="0"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>						
						<th><b>Accessories Name</b></th>	
						<th><b>Select Type</b></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">						
						<td align="center">'.$result['acc_name'].'</td>	
<td align="center">
<input type="hidden" value="'.$result['user_id'].'" name="user_id[]" id="user_id[]">
<input type="hidden" value="'.$result['acc_id'].'" name="acc_id[]" id="acc_id[]">										
<select name="type_acc[]" id="type_acc[]">
<option value="Return" selected="selected">Return</option>
<option value="Home">Retained(Taken home)</option>
<option value="Lost">Lost/Stolen</option>
<option value="Damage">Damaged</option>
</select>
</td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetApproveAccReplacementGrid()
{
$sql = mysql_query('SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, acs.accessories_name, acs.company_name,  acs.dispatch_location, acs.dispatch_date, acs.accessories_id FROM users AS usr INNER JOIN accessories AS acs INNER JOIN replacement_request AS repl ON usr.user_id = acs.user_id
AND acs.accessories_id = repl.product_id WHERE repl.type = "accessories" and repl.approved="0" ORDER BY usr.user_no ASC');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Data Card</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>
						<th><b>Remark</b></th>					
						<th><b>Assign</b></th>
						<th><b>Reject</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><textarea name="accessoriesremarks_'.$result['accessories_id'].'" id="accessoriesremarks_'.$result['accessories_id'].'" rows="1" cols="15"></textarea></td>
						<td align="center"><input type="checkbox" id="assigned_'.$result['accessories_id'].'" name="assigned_'.$result['accessories_id'].'" value="1"></td>					   <td align="center"><img src="images/but_delete.gif"  style="cursor:pointer;" onclick="Disapprove_replacementAcc('.$result['accessories_id'].')"></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}



function GetApprovedLapReplacementGrid()
{
$sql = mysql_query('SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, lpt.laptopmodel, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id
FROM users AS usr INNER JOIN laptop AS lpt INNER JOIN replacement_request AS repl ON usr.user_id = lpt.user_id AND lpt.laptop_id = repl.product_id
WHERE repl.type = "laptop" and repl.approved="0" ORDER BY usr.user_no ASC ');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Model No</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Remark</b></th>					
						<th><b>Assign</b></th>
						<th><b>Reject</b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><textarea name="laptopremarks_'.$result['laptop_id'].'" id="laptopremarks_'.$result['laptop_id'].'" rows="1" cols="15"></textarea></td>
						<td align="center"><input type="checkbox" id="assignedlap_'.$result['laptop_id'].'" name="assignedlap_'.$result['laptop_id'].'" value="1"></td>					   <td align="center"><img src="images/but_delete.gif"  style="cursor:pointer;" onclick="Disapprove_replacementLap('.$result['laptop_id'].')"></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetAccessoriesDataRules()
{
$sql = mysql_query('SELECT * FROM accessories_data');
$data .='<select name="acc_id" id="acc_id">';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[0].'">'.$result[1].'</option>';
}
$data .='</select>';
return $data;
}

function GetAccessoriesData()
{
$sql = mysql_query('SELECT acc.accessoriesdata_id,acc.accessories_name,accstc.depot_location,accstc.quantity FROM accessories_data as acc INNER JOIN accessories_stock as accstc ON acc.accessoriesdata_id = accstc.accessories_id where accstc.quantity!=0');
$data .='<select name="acc_data[]" id="emp_accessories_name" multiple="multiple">';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[1].'">'.$result[1].'-'.$result[2].'</option>';
}
$data .='</select>';
return $data;
}

function GetUserTypes()
{
$sql = mysql_query('SELECT * FROM user_groups where user_groups_id!="7"');
$data .='<select name="user_type" id="user_type">';
$data .='<option value="select">Select User Type</option>';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[0].'">'.$result[1].'</option>';
}
$data .='</select>';
return $data;
}

function GetDepot($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depot" id="depot">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}

function GetEmpDepot($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depot" id="depot">';
$data .='<option value="0" selected="selected">Select</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}




function GetEmpDepotGroup($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depot0" id="depot0">';
$data .='<option value="0" selected="selected">Select</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}


function GetEmpDepotMore($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<option value="0" selected="selected">Select</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
return $data;
}


function GetDepotLocation($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4" order By user_address ASC');
$data .='<select name="depot_location" id="depot_location" onChange="goURL(this.value);">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($_REQUEST['DL']==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}

function GetDepotLoc($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depot_location" id="depot_location" onChange="goURL(this.value);">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($_REQUEST['DL']==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}


function GetAccDepotLocation($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depot_location" id="depot_location">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($_REQUEST['DL']==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}

function GetDepottransfer($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="depotto" id="depotto" onChange="Dispatch(this.value);">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}




function GetDivisionName($value)
{
$sql = mysql_query('SELECT division_name FROM division');
$data .='<select name="division" id="division">';
$data .='<option value="0" selected="selected">Select division</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}





function GetDivisionNameGroup($value)
{
$sql = mysql_query('SELECT division_name FROM division');
$data .='<select name="division0" id="division0">';
$data .='<option value="0" selected="selected">Select division</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}










function GetAccCompanyName()
{
$sql = mysql_query('SELECT datacard_name,card_no,depot_location FROM data_card where status=0');
$data .='<select name="emp_company_name" id="emp_company_name">';
$data .='<option value="0" selected="selected">Select Data Card</option>';

while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[0].'">'.$result[0].'-'.$result[1].'-'.$result[2].'</option>';
}
$data .='</select>';
return $data;
}


function GetLaptopModelName($value)
{
 if($_SESSION['user_groups_id']=="7") 
	{
		if($value=="")
        {
		  $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status,box_no FROM `laptop_details` where status!=0 and laptop_type!="SD" and  depot_location="'.$_REQUEST['DL'].'"');
			$data .='<select name="laptop_model" id="laptop_model">';
			$data .='<option value="0" selected="selected">Select Laptop Model</option>';
				while($result = mysql_fetch_row($sql))
				{
						if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
						{
						$select ='selected="selected"';
						}
						else
						{
						$select ='';
						}

					  if($result[4]=="2")
					  {
						 $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-ONHOLD</option>';
					  }
					  else
					  {
						 $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>'; 
					  }
             }
			 $data .='</select>';
	     }
	     else
		 {

				$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location  FROM `laptop_details` where status!=0  AND depot_location="'.$_REQUEST['DL'].'"');
				$data .='<select name="laptop_model" id="laptop_model">';
				$data .='<option value="0" selected="selected">Select Laptop Model</option>';
				while($result = mysql_fetch_row($sql))
				{
					if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
					{
					$select ='selected="selected"';
					}
					
					
					else
					{
					$select ='';
					}

					$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
				}

				$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
				$data .='</select>';
		  }
     }
	 elseif($_SESSION['user_groups_id']=="8")
	 {
	    if($value=="")
         {

			  $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status FROM `laptop_details` where status="1" and laptop_type!="SD" and depot_location="'.$_REQUEST['DL'].'"');
			$data .='<select name="laptop_model" id="laptop_model">';
			$data .='<option value="0" selected="selected">Select Laptop Model</option>';
			   while($result = mysql_fetch_row($sql))
			    {
					if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
					{
					$select ='selected="selected"';
					}
					else
					{
					$select ='';
					}
					
					$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';

               }
			
            $data .='</select>';
         }
		 else
		{
			
				$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status FROM `laptop_details` where status!=0 and depot_location="'.$_REQUEST['DL'].'"');
				$data .='<select name="laptop_model" id="laptop_model">';
				$data .='<option value="0" selected="selected">Select Laptop Model</option>';
					while($result = mysql_fetch_row($sql))
					{
						if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
						{
						$select ='selected="selected"';
						}
						else
						{
						$select ='';
						}
					
					$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
				  }
			
			$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
			$data .='</select>';
			
			
       }
	 
  }
     elseif($_SESSION['user_groups_id']!="7" ||$_SESSION['user_groups_id']!="6" || $_SESSION['user_groups_id']!="8")
	   {
	       if($value=="")
            {
				$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no FROM `laptop_details` where status=1 and laptop_type!="SD" and depot_location="'.$_REQUEST['DL'].'" order by laptop_condition DESC limit 0,3');
				$data .='<select name="laptop_model" id="laptop_model">';
				$data .='<option value="0" selected="selected">Select Laptop Model</option>';
				while($result = mysql_fetch_row($sql))
				{
					if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
					{
					$select ='selected="selected"';
					}
					else
					{
					$select ='';
					}
			       $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
              }		
			  $data .='</select>';
          }
		  else
          {
     		$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location  FROM `laptop_details` where status=1 and depot_location="'.$_REQUEST['DL'].'"');
			$data .='<select name="laptop_model" id="laptop_model">';
			$data .='<option value="0" selected="selected">Select Laptop Model</option>';
			while($result = mysql_fetch_row($sql))
			{
				if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
				{
				$select ='selected="selected"';
				}
				else
				{
				$select ='';
				}
			 $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
          }
		  $data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
          $data .='</select>';
	}	  
}


 return $data;
}



function GetLaptopModelName1($value)
{
if($value=="")
{
$sql = mysql_query('SELECT DISTINCT(laptop_name),laptop_model,depot_location,serial_no FROM `laptop_details` where status=1 and depot_location="'.$_REQUEST['DL'].'"');
$data .='<select name="laptop_model1" id="laptop_model1"><option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
{
if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
{
$select ='selected="selected"';
}
else
{
$select ='';
}

$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
}
$data .='</select>';
}
else
{

$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no  FROM `laptop_details` where status=1 and depot_location="'.$_REQUEST['DL'].'"');
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
{
if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
{
$select ='selected="selected"';
}
else
{
$select ='';
}

$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
}

$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';


}
$data .='</select>';
return $data;
}


/*function GetLaptopModelNameMT($value)
{
if($value=="")
{
 $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no FROM `laptop_details` where status=1 and laptop_condition!=0 and depot_location="'.$_REQUEST['DL'].'" order by laptop_condition des limit 0,3');

$sql2 = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no  FROM `laptop_details` where status=1');
$data .='<option value="0" selected="selected">Select Laptop Model</option>';

while($result = mysql_fetch_row($sql))
{
$flag = 1;
if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
{
$select ='selected="selected"';
}
else
{
$select ='';
}
$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
}



if($flag!=1)
{
while($result = mysql_fetch_row($sql2))
{
if($value==$result[0].'-'.$result[1].'-'.$result[3])
{
$select ='selected="selected"';
}
else
{
$select ='';
}
$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';

}
}

}
else
{

 $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no FROM `laptop_details` where status=1 and laptop_condition!=0 and depot_location="'.$_REQUEST['DL'].'"');


$sql2 = mysql_query('SELECT DISTINCT(laptop_name),laptop_model,depot_location  FROM `laptop_details` where status=1 and depot_location="'.$_REQUEST['DL'].'"');
$data .='<select name="laptop_model1" id="laptop_model">';
$data .='<option value="0" selected="selected">Select Laptop Model</option>';

while($result = mysql_fetch_row($sql))
{
$flag = 1;
if($value==$result[0].'-'.$result[1].'-'.$result[3])
{
$select ='selected="selected"';
}
else
{
$select ='';
}
$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
}



if($flag!=1)
{
while($result = mysql_fetch_row($sql2))
{
if($value==$result[0].'-'.$result[1].'-'.$result[3])
{
$select ='selected="selected"';
}
else
{
$select ='';
}
$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
}
}
$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
$data .='</select>';
}
return $data;
}*/



function GetDesignationName($value)
{
$sql = mysql_query('SELECT designation_name FROM designation');
$data .='<select name="user_desn" id="user_desn">';
$data .='<option value="0" selected="selected">Select designation</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}



function GetEmpDesignationName($value)
{
$sql = mysql_query('SELECT designation_name FROM designation');
/*$data .='<select name="emp_desn" id="emp_desn" onChange="GetLapModel(this.value);">';*/
$data .='<select name="emp_desn" id="emp_desn"">';
$data .='<option value="0" selected="selected">Select designation</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}




function GetEmpDesignationNameGroup($value)
{
$sql = mysql_query('SELECT designation_name FROM designation');
/*$data .='<select name="emp_desn0" id="emp_desn0" onChange="GetLapModel(this.value);">';*/
$data.='<select name="emp_desn0" id="emp_desn0">';
$data .='<option value="0" selected="selected">Select designation</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}


function GetEmpDesignationNameMore($value)
{
$sql = mysql_query('SELECT designation_name FROM designation');
$data .='<option value="0" selected="selected">Select designation</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
return $data;
}




function GetLaptopDepotName($value)
{
$val  = explode('-',$value);
$sql = mysql_query("SELECT depot_location FROM `laptop_details` WHERE laptop_name ='".trim($val[0])."' and laptop_model ='".trim($val[1])."'");
while($result = mysql_fetch_row($sql))
{
$data .= array();
$data .= $result[0];
}
return $data;
}







function GetLaptopDepotNameAPP($value,$value2)
{
$val  = explode('-',$value);
$sql = mysql_query("SELECT depot_location FROM `laptop_details` WHERE laptop_name ='".trim($val[0])."' and laptop_model ='".trim($val[1])."' and serial_no='".$value2."'");
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}










function GetLaptopAcc()
{
$sql = mysql_query('SELECT acc_name FROM laptop_acc');
$data .='<select name="laptop_acc[]" id="laptop_acc" multiple>';
$data .='<option value="0" >Select Laptop Accessories</option>';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[0].'" selected="selected">'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}

function GetReceivedLapTechGrid($id)
{
 $sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.serial_no,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,usr.user_id FROM users as usr INNER JOIN  laptop as lpt INNER JOIN return_laptop as rl ON  usr.user_id = lpt.user_id and lpt.laptop_id = rl.laptop_id where usr.user_no="'.trim($id).'" and rl.received ="0" and rl.status = "Return" and lpt.returned ="1"');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Received</b></th>
						<th></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">';
						if($result[9]=="1")
						{					
						
$data .=				'<input type="hidden" name="laptop_id" value="'.$result['laptop_id'].'">
<input type="checkbox" name="type" id="type" value="'.$result['laptop_id'].'-'.$result['user_id'].'" checked="checked">';
						}
						else
						{
$data .='<input type="checkbox" name="type" id="type" value="'.$result['laptop_id'].'-'.$result['user_id'].'">';
						}
						
$data .='</td>
</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetReceivedLapAccTechGrid($id)
{
$sql = mysql_query('SELECT la.acc_name from laptop_acc la INNER JOIN laptop_acc_details as lad INNER JOIN users as usr INNER JOIN returned_laptops_acc as rlc where lad.accessories_id=la.acc_id and usr.user_id=lad.user_id and lad.accessories_id=rlc.accessories_id and lad.user_id=rlc.user_id and usr.user_no="'.trim($id).'" and rlc.received ="0" and rlc.status = "Return"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Accessories Name</b></th>	
						<th><b>Select Type</b></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['acc_name'].'</td>	
<td align="center">									
<input type="checkbox" name="type_acc[]" id="type_acc[]" value="'.$result['0'].'">
</td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetReceivedAccTechGrid($id)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.company_name,acs.dispatch_location,acs.accessories_id,acs.depot_location FROM users as usr INNER JOIN accessories as acs INNER JOIN return_accessories as ra ON  usr.user_id = acs.user_id and acs.accessories_id = ra.accessories_id and acs.user_id = ra.user_id where usr.user_no="'.trim($id).'" and ra.received="0"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Company Name</b></th>
						<th><b>Dispatch Location</b></th>																		
						<th><b>Recieved</b></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>						
						<td align="center">'.$result['company_name'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>						
<td align="center">	
<input type="hidden" name="acc_id[]" id="acc_id[]" value="'.$result['accessories_id'].'">
<input type="hidden" name="depot_loc[]" id="depot_loc[]" value="'.$result['depot_location'].'">								
<input type="checkbox" name="acc[]" id="acc[]" value="'.$result['accessories_name'].'">
</td>
						</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetReturnLapTechGrid($id)
{
$sql = mysql_query('SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, lpt.laptopmodel, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id,lpt.serial_no
FROM users AS usr INNER JOIN laptop AS lpt INNER JOIN return_laptop AS rl ON usr.user_id = lpt.user_id AND lpt.laptop_id = rl.laptop_id
WHERE usr.user_no="'.trim($id).'" and rl.status = "Return" and rl.received="1" ORDER BY usr.user_no ASC');

$sql3=mysql_query("Select max(box_no) as boxes from laptop_details");
$result3 = mysql_fetch_array($sql3);
$newboxno = $result3['boxes']+1;		

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>											
						<th><b>Box No</b></th>
						<th><b>Status</b></th>
						<th></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">'.$newboxno.'</td>
						<td align="center">
						<input type="hidden" name="laptop_id" id="laptop_id" value="'.$result['laptop_id'].'">
						<input type="hidden" name="serial_no" id="serial_no" value="'.$result['serial_no'].'"><select name="type" id="type">
<option value="Available" selected="selected">Available - free</option>
<option value="Onhold">Available-on hold</option>
<option value="DamagedU">Damaged - Repair under warranty</option>
<option value="DamagedO">Damaged - repair out of warranty</option>
<option value="Substitute">Substitute Use</option>

</select>
</td>
</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

//bhavika added changes over here
function GetReturnLapAccTechGrid($id)
{
$sql = mysql_query('select la.acc_name,la.acc_id,usr.user_no,lad.user_id from laptop_acc as la,laptop_acc_details as lad,users as usr,returned_laptops_acc as rlc where la.acc_id = lad.accessories_id and lad.user_id=usr.user_id and rlc.user_id=usr.user_id and la.acc_id=rlc.accessories_id and usr.user_no="'.trim($id).'" and rlc.received="1"');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Select Type</b></th>	
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['0'].'</td>
						<td align="center"><input type="hidden" name="acc_id[]" id="acc_id[]" value="'.$result['acc_id'].'"><select name="LapAcctype[]" id="LapAcctype[]">
<option value="Available" selected="selected">Available - free</option>
<option value="Damaged">Damaged</option>
</select>
</td>
</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetReturnAccTechGrid($id)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,acs.accessories_name,acs.card_no,acs.company_name,acs.dispatch_location,acs.depot_location,acs.accessories_id,acs.user_id FROM users as usr INNER JOIN accessories as acs INNER JOIN return_accessories as rac ON  usr.user_id = acs.user_id where acs.accessories_id=rac.accessories_id and acs.user_id=rac.user_id and usr.user_no="'.trim($id).'" and rac.received="1"');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card No</b></th>	
						<th><b>Company Name</b></th>
						<th><b>Depot Location</b></th>
						<th><b>Dispatch Location</b></th>						
						<th><b>Select Type</b></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>						
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['depot_location'].'</td>					
						<td align="center">'.$result['dispatch_location'].'</td>	
<td align="center"><input type="hidden" name="accessories_id[]" id="accessories_id[]" value="'.$result['accessories_id'].'"><input type="hidden" name="accessories_name[]" id="accessories_name[]" value="'.$result['accessories_name'].'"><input type="hidden" name="depot_location[]" id="depot_location[]" value="'.$result['depot_location'].'"><input type="hidden" name="card_no[]" id="card_no[]" value="'.$result['card_no'].'"><input type="hidden" name="company[]" id="company[]" value="'.$result['company_name'].'">
<select name="Acctype[]" id="Acctype[]">
<option value="Available" selected="selected">Available</option>
<option value="Damaged">Damaged</option>
</select>
</td>				</tr>						
					';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetLaptopTypeS($value)
{
$sql = mysql_query('SELECT DISTINCT(laptop_name),laptop_model  FROM `laptop_details` where status=1 and laptop_type="S"');
$data .='<select name="laptop_model1" id="laptop_model">';
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
}
$data .='</select>';
return $data;
}








function GetLaptopModelNameTransfer($value)
{

if($value=="")
{
$sql = mysql_query('SELECT ld.laptop_name,ld.laptop_model FROM laptop_details as ld join laptop as lpt ON ld.serial_no = lpt.serial_no join return_laptop as rl ON rl.laptop_id = lpt.laptop_id');

$data .='<select name="laptop_model" id="laptop_model" onChange="GetSerialNo(this.value)">';
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
{
if($value==trim($result[0]).'-'.trim($result[1]))
{
$select ='selected="selected"';
}
else
{
$select ='';
}

$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'</option>';
}
$data .='</select>';
}
else
{

$sql = mysql_query('SELECT ld.laptop_name,ld.laptop_model FROM laptop_details as ld join laptop as lpt ON ld.serial_no = lpt.serial_no join return_laptop as rl ON rl.laptop_id = lpt.laptop_id');
$data .='<select name="laptop_model" id="laptop_model">';
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
{
if($value==trim($result[0]).'-'.trim($result[1]))
{
$select ='selected="selected"';
}
else
{
$select ='';
}

$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'</option>';
}

$data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
$data .='</select>';


}
return $data;
}



function GetSerialNo($value)
{
$val_array = explode('-',$value);
$sql = mysql_query('SELECT serial_no FROM `laptop_details` where laptop_name="'.trim($val_array[0]).'" and laptop_model="'.trim($val_array[1]).'" and status="1"');
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.$result[0].'">'.$result[0].'</option>';
}
return $data;
}



function GetLapModel($value)
{
$sql = mysql_query('SELECT 	laptopmodel  FROM `laptop` where laptop_id="'.trim($value).'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}

function GetLapSerial($value)
{
$sql = mysql_query('SELECT 	serial_no FROM `laptop` where laptop_id="'.trim($value).'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}

function GetLapDLoc($value)
{
$sql = mysql_query('SELECT 	dispatch_location FROM `laptop` where laptop_id="'.trim($value).'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}

function GetUserID($value)
{
$sql = mysql_query('SELECT user_id FROM `users` where user_no ="'.$value.'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}


function GetSubstLapType($value)
{
$sql = mysql_query('SELECT laptop_type FROM `laptop_details` where serial_no ="'.$value.'"');
while($result = mysql_fetch_row($sql))
{
$data .= $result[0];
}
return $data;
}









function GetRepairListGrid($value)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.recived,lpt.acc FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where lpt.assigned="1" and lpt.dispatch="1" and usr.user_no="'.trim($value).'" ORDER BY  usr.user_no  Asc');



if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>		
						<th><b>Accessories</b></th>			
						<th><b>Remarks</b></th>
						<th>Repair</th>
					</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">'.$result['acc'].'</td>
    					<td align="center"><textarea name="repairremarks_'.$result['laptop_id'].'" id="repairremarks_'.$result['laptop_id'].'" rows="1" cols="15"></textarea></td>

						<td align="center"><input type="checkbox" id="repair_'.$result['laptop_id'].'"  name="repair_'.$result['laptop_id'].'" value="1"></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}




function GetSubstituteListGrid($value)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,usr.depot,lpt.division,lpt.laptopmodel,lpt.region,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.recived FROM users as usr INNER JOIN  laptop as lpt ON  usr.user_id = lpt.user_id where lpt.assigned="1" and lpt.dispatch="1" and usr.user_no="'.trim($value).'"');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>		
						<th><b>Assign Substitute as Original</b></th>
					</tr>';
while($result = mysql_fetch_array($sql)){


if(strtoupper(GetSubstLapType($result['serial_no']))!="O")
{
$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><input type="checkbox" id="original_'.$result['laptop_id'].'"  name="original_'.$result['laptop_id'].'" value="1"></td>
						</tr>';
						}
						
}						
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetSubstituteAccListGrid($id)
{
  
$sql = mysql_query('SELECT usr.user_no, usr.user_firstname, usr.user_lastname, usr.depot, acc.division, acc.accessories_name, acc.region, acc.dispatch_location, acc.card_no, acc.company_name FROM users AS usr INNER JOIN accessories AS acc ON usr.user_id = acc.user_id
WHERE acc.assigned = "1" AND acc.dispatch = "1" AND usr.user_no ="'.trim($id).'"');



if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="1010"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Division</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Company Name</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>						
						<th><b>Card Number</b></th>		
						<th><b>Assign Data Card</b></th>
					</tr>';
while($result = mysql_fetch_array($sql)){


if($result['card_no']!="")
{
$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['division'].'</td>						
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['company_name'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>											
						<td align="center">'.$result['card_no'].'</td>
						<td align="center"><input type="checkbox" id="card_no"  name="card_no" value="'.$result['card_no'].'"></td>
						</tr>';
						}
						
}						
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="1010"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;

}

function GetLaptopModelNameORGNSUBST($value)
{
$sql = mysql_query('SELECT DISTINCT(laptop_name),laptop_model FROM `laptop_details` where status=1 and laptop_type="'.trim($value).'" and depot_location="'.$_REQUEST['DL'].'"');
$data .='<select name="laptop_model" id="laptop_model">';
while($result = mysql_fetch_row($sql))
{
$data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'" '.$select.'>'.trim($result[0]).'-'.trim($result[1]).'</option>';
}
$data .='</select>';
return $data;
}




function GetUserDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT usr.user_id,usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_password,usr.user_name,usr.user_designation,usr.depot,lpt.division,lpt.laptopmodel,lpt.region,lpt.dispatch_location,lpt.dispatch_date FROM users as usr LEFT JOIN  laptop as lpt ON  usr.user_id = lpt.user_id LEFT JOIN accessories as acs ON usr.user_id=acs.user_id where usr.user_groups_id!="1"  ORDER BY  usr.user_no  Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee First Name</b></th>
						<th><b>Employee Last Name</b></th>
						<th><b>User Name</b></th>
						<th><b>Password</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>		
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['user_firstname'].'</td>
						<td align="center">'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_name'].'</td>
						<td align="center">'.$result['user_password'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><a href="user_details.php?id='.$result['user_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetUserLaptopDetailsGrid()
{
$sql = mysql_query('SELECT usr.user_id,usr.user_firstname,usr.user_lastname,lpt.laptopmodel,lpt.serial_no FROM `laptop` as lpt INNER JOIN `users` as usr ON lpt.user_id = usr.user_id ORDER BY  usr.user_no Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee First Name</b></th>
						<th><b>Employee Last Name</b></th>
						<th><b>Laptop Model</b></th>
						<th><b>Laptop Serial</b></th>						
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['user_firstname'].'</td>
						<td align="center">'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>						
						<td align="center"><a href="user_laptop_details.php?id='.$result['user_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetUserDatacardDetailsGrid()
{
$sql = mysql_query('SELECT usr.user_id,usr.user_firstname,usr.user_lastname,acc.accessories_name,acc.card_no FROM `accessories` as acc INNER JOIN `users` as usr ON acc.user_id = usr.user_id where accessories_name = "Data card" ORDER BY usr.user_no Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee First Name</b></th>
						<th><b>Employee Last Name</b></th>
						<th><b>Accessories Name</b></th>
						<th><b>Card No.</b></th>	
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['user_firstname'].'</td>
						<td align="center">'.$result['user_lastname'].'</td>
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>
						<td align="center"><a href="user_datacard_details.php?id='.$result['user_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}


function GetDivisionDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT division_id,division_name,description FROM division');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>						
						<th><b>Division Name</b></th>
						<th><b>Description</b></th>							
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['division_name'].'</td>
						<td align="center">'.$result['description'].'</td>						
						<td align="center"><a href="division_details.php?id='.$result['division_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetDesignationDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT designation_id,designation_name,description FROM designation');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Designation Name</b></th>
						<th><b>Description</b></th>						
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['designation_name'].'</td>
						<td align="center">'.$result['description'].'</td>
						<td align="center"><a href="designation_details.php?id='.$result['designation_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetAccessoriesDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT accessoriesdata_id,accessories_name,description FROM accessories_data');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Description</b></th>						
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['description'].'</td>
						<td align="center"><a href="accessories_details.php?id='.$result['accessoriesdata_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetDatacardDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT datacard_id,datacard_name,card_no,RSN_no,box_no,depot_location FROM data_card');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Datacard Name</b></th>
						<th><b>Card No</b></th>
						<th><b>RSN No</b></th>
						<th><b>Box No</b></th>
						<th><b>Depot Location</b></th>										
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['datacard_name'].'</td>
						<td align="center">'.$result['card_no'].'</td>
						<td align="center">'.$result['RSN_no'].'</td>
						<td align="center">'.$result['box_no'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center"><a href="datacard_details.php?id='.$result['datacard_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetDispalyLaptopDetailsGrid()
{
$sql = mysql_query('SELECT DISTINCT laptop_id,laptop_name,laptop_model,status,box_no,serial_no,manufactured_date,depot_location,laptop_condition,laptop_type FROM laptop_details');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>laptop_name</b></th>
						<th><b>laptop_model</b></th>
						<th><b>status</b></th>
						<th><b>box_no</b></th>
						<th><b>serial_no</b></th>
						<th><b>manufactured_date</b></th>
						<th><b>depot_location</b></th>
						<th><b>laptop_condition</b></th>
						<th><b>laptop_type</b></th>												
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['laptop_name'].'</td>
						<td align="center">'.$result['laptop_model'].'</td>
						<td align="center">'.$result['status'].'</td>
						<td align="center">'.$result['box_no'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['manufactured_date'].'</td>
						<td align="center">'.$result['depot_location'].'</td>
						<td align="center">'.$result['laptop_condition'].'</td>
						<td align="center">'.$result['laptop_type'].'</td>
						<td align="center"><a href="display_laptop_details.php?id='.$result['laptop_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetAccessoriesRulesDetailsGrid()
{
$sql = mysql_query('SELECT acc.accessories_rules_id,acc.accessories_id,acc.days,accdata.accessoriesdata_id,accdata.accessories_name FROM accessories_rules as acc INNER JOIN  accessories_data as accdata where acc.accessories_id=accdata.accessoriesdata_id');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Accessories Name</b></th>
						<th><b>Days</b></th>						
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['accessories_name'].'</td>
						<td align="center">'.$result['days'].'</td>
						<td align="center"><a href="accessories_rules_details.php?id='.$result['accessories_rules_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetLaptopOnHold()
{
$sql = mysql_query("SELECT * FROM laptop_details WHERE status=2"); 

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980">
                        <tr>
						<th><b>Laptop Model</b></th>
						<th><b>Serial No</b></th>
						<th><b>Box No</b></th>
						<th><b>Depot Location</b></th>						
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">					
						<td align="center">'.$result['laptop_model'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['box_no'].'</td>						
						<td align="center">'.$result['depot_location'].'</td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

/*function GetUserDetailsACCGrid()
{
$sql = mysql_query('SELECT DISTINCT usr.user_id,
usr.user_no,usr.user_firstname,usr.user_lastname,usr.user_designation,acs.division,acs.region,acs.depot,acs.dispatch_location,acs.dispatch_date FROM users as usr INNER JOIN accessories as acs ON usr.user_id = acs.user_id  ORDER BY  usr.user_no  Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee First Name</b></th>
						<th><b>Employee Last Name</b></th>
						<th><b>Employee Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Region</b></th>
						<th><b>Depot</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>		
						<th>&nbsp;</th>			
						</tr>';
while($result = mysql_fetch_array($sql)){


                     
					

$data .= '<tr class="odd">
						<td align="center">'.$result['user_firstname'].'</td>
						<td align="center">'.$result['user_lastname'].'</td>
						<td align="center">'.$result['user_designation'].'</td>
						<td align="center">'.$result['division'].'</td>
						<td align="center">'.$result['region'].'</td>						
						<td align="center">'.$result['depot'].'</td>						
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center"><a href="user_details.php?id='.$result['user_id'].'"><input type="button" value="Edit"></a></td>
						</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}*/






function GetLaptopModelNameGroup($value)
{
if($_SESSION['user_groups_id']=="7")
 {
$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status,box_no FROM `laptop_details` where status!=0 AND laptop_type!="SD" AND depot_location="'.$_REQUEST['DL'].'"');
$data .='<select name="laptop_model0" id="laptop_model0">';
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
   {
       if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
         {
           $select ='selected="selected"';
         }
       else
         {
            $select ='';
         }
           if($result[4]=="1")
            {
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.  trim($result[2]).'-'.trim($result[3]).'</option>';
            }
          else
           {
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-ONHOLD</option>';
          }
   }
$data .='</select>';
}
elseif($_SESSION['user_groups_id']=="8")
{
 $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status,box_no FROM `laptop_details` where status=1 AND laptop_type!="SD" and depot_location="'.$_REQUEST['DL'].'"');
 $data .='<select name="laptop_model0" id="laptop_model0">';
 $data .='<option value="0" selected="selected">Select Laptop Model</option>';
 while($result = mysql_fetch_row($sql))
   {
       if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
         {
           $select ='selected="selected"';
         }
       else
         {
            $select ='';
         }
		 $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.  trim($result[2]).'-'.trim($result[3]).'</option>';
   }
  $data .='</select>'; 		 
 }
elseif($_SESSION['user_groups_id']!="7"||$_SESSION['user_groups_id']!="6"||$_SESSION['user_groups_id']!="8")
{
   $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,box_no FROM `laptop_details` where status=1 AND laptop_type!="SD" AND depot_location="'.$_REQUEST['DL'].'" order by laptop_condition DESC limit 0,3');
   $data .='<select name="laptop_model" id="laptop_model">';
   $data .='<option value="0" selected="selected">Select Laptop Model</option>';
      while($result = mysql_fetch_row($sql))
       {
          if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
           {
               $select ='selected="selected"';
           }
         else
          {
              $select ='';
          }
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
     }
	 $data .='</select>'; 
}

return $data;
}







function GetDivisionNameGroupMore($value)
{
$sql = mysql_query('SELECT division_name FROM division');
$data .='<option value="0" selected="selected">Select division</option>';
while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
return $data;
}






function GetLaptopModelNameGroupMore($value)
{

if($_SESSION['user_groups_id']=="7")
 {
$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status,box_no FROM `laptop_details` where status!=0 and laptop_type!="SD" and depot_location="'.$_REQUEST['DL'].'"');
$data .='<option value="0" selected="selected">Select Laptop Model</option>';
while($result = mysql_fetch_row($sql))
   {
       if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
         {
           $select ='selected="selected"';
         }
       else
         {
            $select ='';
         }
           if($result[4]=="1")
            {
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.  trim($result[2]).'-'.trim($result[3]).'</option>';
            }
          else
           {
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-ONHOLD</option>';
          }
   }

}
elseif($_SESSION['user_groups_id']=="8")
{
 $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,status,box_no FROM `laptop_details` where status=1 and laptop_type!="SD" and depot_location="'.$_REQUEST['DL'].'"');
 $data .='<option value="0" selected="selected">Select Laptop Model</option>';
 while($result = mysql_fetch_row($sql))
   {
       if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
         {
           $select ='selected="selected"';
         }
       else
         {
            $select ='';
         }
		 $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.  trim($result[2]).'-'.trim($result[3]).'</option>';
   }		 
 }
elseif($_SESSION['user_groups_id']!="7"||$_SESSION['user_groups_id']!="6"||$_SESSION['user_groups_id']!="8")
{
   $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,box_no FROM `laptop_details` where status=1 and  laptop_type!="SD" AND depot_location="'.$_REQUEST['DL'].'" order by laptop_condition DESC limit 0,3');

   $data .='<option value="0" selected="selected">Select Laptop Model</option>';
      while($result = mysql_fetch_row($sql))
       {
          if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
           {
               $select ='selected="selected"';
           }
         else
          {
              $select ='';
          }
             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[5]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
     }
	 
}

return $data;
}


function GetPendingRequestGrid()
{
$sql = mysql_query('SELECT usr.user_id, usr.user_no,usr.user_firstname,usr.user_designation,usr.user_lastname,usr.user_designation,lpt.division,lpt.laptopmodel,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no,lpt.depot_location,lpt.dispatch_location_add FROM users as usr INNER JOIN pending_request as lpt ON  usr.user_id = lpt.user_id ORDER BY  usr.user_no  Asc');

if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Designation</b></th>
						<th><b>Division</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Region</b></th>						
						<th><b>Dispatch From Location</b></th>
						<th><b>Dispatch To Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b></b></th>
						</tr>';
while($result = mysql_fetch_array($sql)){


                        if($result['user_designation']=='MT')
						{
						$lapModel = GetLaptopModelNameMT($result['laptopmodel']);
						$laptop_model = $_POST['laptop_model1'];
						}
						else
						{
				        $lapModel = GetLaptopModelName($result['laptopmodel']);
						$laptop_model = $_POST['laptop_model'];
						}
						


$data .= '<tr class="odd">
<form name="frmApproveLaptops" id="frmApproveLaptops" action="pending_request_process.php" method="post">
<td align="center">'.$result['user_no'].'</td><input type="hidden" name="userid" value="'.$result['user_id'].'">
<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
<td align="center">'.$result['user_designation'].'</td>
<td align="center">'.$result['division'].'</td><input type="hidden" name="division" value="'.$result['division'].'">					
<td align="center"><select name="laptop_model" id="laptop_model"><option>Select Laptop Model</option>';
$sql1 = mysql_query('SELECT lpd.laptop_name,lpd.laptop_model,lpd.depot_location,lpd.serial_no FROM laptop_details as lpd where lpd.status = "1" and lpd.depot_location="'.$result['depot_location'].'"');
												
					while($result1 = mysql_fetch_array($sql1)){
$data .='<option value="'.trim($result1[0]).'-'.trim($result1[1]).'-'.trim($result1[3]).'" '.$select.'>'.trim($result1[0]).'-'.trim($result1[1]).'-'.trim($result1[2]).'-'.trim($result1[3]).'</option>';
					}
$data .= '</td><td align="center">'. $result['serial_no']	.'</td><input type="hidden" name="serial_no" value="'.GetSerialNo($laptop_model).'">
<td align="center">'.$result['region'].'</td><input type="hidden" name="region" value="'.$result['region'].'">						
<td align="center">'.$result['depot_location'].'</td><input type="hidden" name="depot_location" value="'.$result['depot_location'].'">						
<td align="center">'.$result['dispatch_location'].'</td><input type="hidden" name="dispatch_location" value="'.$result['dispatch_location'].'">					
<td align="center">'.$result['dispatch_date'].'</td><input type="hidden" name="dispatch_date" value="'.$result['dispatch_date'].'">
<input type="hidden" name="dispatch_location_address" value="'.$result['dispatch_location_add'].'">
<input type="hidden" name="desn" value="'.$result['user_designation'].'">

<td align="center"><input type="Submit" Value="UPDATE" name="submit"></td>
</form>
</tr>';
}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function getDeliverydate($id)
{
$sql = mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,da.date,da.accessories_id,acs.accessories_id,acs.user_id  FROM users as usr JOIN  dispatched_accessories as da JOIN accessories as acs ON  usr.user_id = acs.user_id and da.accessories_id = acs.accessories_id where usr.user_no="'.trim($id).'"');
while($result = mysql_fetch_array($sql)){
$data = $result['date'];
}
return $data;
}

function getDaysfromAccRules($acc)
{
$sql = mysql_query('SELECT ad.accessoriesdata_id,ad.accessories_name,ar.days FROM accessories_data as ad INNER JOIN accessories_rules as ar ON  ar.accessories_id  = ad.accessoriesdata_id  where ad.accessories_name="'.$acc.'"');
while($result = mysql_fetch_array($sql)){
$data = $result['days'];
}
return $data;
}

function GetDispatchLocation($value)
{
$sql = mysql_query('SELECT user_address FROM users where user_groups_id="4"');
$data .='<select name="dispatch_location" id="dispatch_location" onChange="Dispatch(this.value);">';
$data .='<option value="0" selected="selected">Select</option>';

while($result = mysql_fetch_row($sql))
{
if($value==$result[0])
{
$select = 'selected="selected"';
}
else
{
$select = '';
}

$data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
}
$data .='</select>';
return $data;
}

function displayArrayTableExportExcel($array_table_header, $array_table,$excelFileName){
	//echo "<pre>";
	//print_r($array_table_header);
	//die();
	
	$header	='';
	$data	='';
		for($i=0; $i<count($array_table); $i++){
			if($i == 0) {
				for($j=0; $j<count($array_table_header); $j++){
					$header	.= strip_tags($array_table_header[$j])."\t";
				}
			}
			for($j=0; $j<count($array_table[0]); $j++){
				if(stripslashes(strip_tags($array_table[$i][$j]))=='')
					$data.='---';
				else
					$data .= stripslashes(strip_tags($array_table[$i][$j]));
				$data .= "\t";
				}
			$data .= "\n";
		}
		
	   	session_cache_limiter('must-revalidate');
		header('Content-Type: application/vnd.ms-excel; name="excel"');
		header('Expires: ' . gmdate('D, d M Y H:i:s') . 'GMT');
		header('Content-Disposition: attachment; filename="' . $excelFileName . '"');
		header('Content-Type: application/x-msdownload;');
		if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
			header('Pragma: public');
		} else {
			header('Pragma: no-cache');
		}
		echo trim($header."\n".$data);
	}

function GetSubstiLaptop($value)
	 {
	   if($_SESSION['user_groups_id']=="7")
	     {
		 if($value=="")
         {
			$sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,laptop_type,status,box_no FROM `laptop_details` where status!="0" ');
			$data .='<select name="laptop_model" id="laptop_model">';
			$data .='<option value="0" selected="selected">Select Laptop Model</option>';
			  while($result = mysql_fetch_row($sql))
				{
                  if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
					{
					$select ='selected="selected"';
					}
				  else
					{
					$select ='';
					}
					if($result[5]=="2")
			         {
			             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[6]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-ONHOLD</option>';
			         } 
			       elseif($result[4]=="S")
			        {
                       $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[6]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-S</option>';
		            }
			        elseif($result[4]=="O")
			        {
			             $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[6]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'-O</option>';
			       }
            }
      $data .='</select>';
       }
	   else
       {
        $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,status,laptop_type,box_no FROM `laptop_details` where status!="0" and laptop_type="S" and depot_location="'.$_REQUEST['DL'].'"');
       $data .='<select name="laptop_model" id="laptop_model">';
       $data .='<option value="0" selected="selected">Select Laptop Model</option>';
         while($result = mysql_fetch_row($sql))
          {
             if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
            {
               $select ='selected="selected"';
            }
             else
            {
               $select ='';
            }
			
        }

       $data .='<option value="'.$value.'"  selected="selected">'.$value.'</option>';
       $data .='</select>';
    }
  } 
  elseif($_SESSION['user_groups_id']=="8")
  {
     
	     $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,box_no FROM `laptop_details` where status="1" and laptop_type="S"');
	 	 $data .='<select name="laptop_model" id="laptop_model">';
		 $data .='<option value="0" selected="selected">Select Laptop Model</option>';
			 while($result = mysql_fetch_row($sql))
				{
                  if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
					{
					$select ='selected="selected"';
					}
				  else
					{
					$select ='';
					}
				

        $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[4]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
           }
      $data .='</select>';
        
  }

  elseif($_SESSION['user_groups_id']!="7" || $_SESSION['user_groups_id']!="6" || $_SESSION['user_groups_id']!="8")
  {
       $sql = mysql_query('SELECT laptop_name,laptop_model,depot_location,serial_no,box_no FROM `laptop_details` where status=1 and laptop_type="S" order by laptop_condition DESC limit 0,3');
       $data .='<select name="laptop_model" id="laptop_model">';
       $data .='<option value="0" selected="selected">Select Laptop Model</option>';
         while($result = mysql_fetch_row($sql))
          {
               if($value==trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]))
                {
                   $select ='selected="selected"';
                }
              else
              {
                $select ='';
              }
			  		  	
              $data .='<option value="'.trim($result[0]).'-'.trim($result[1]).'-'.trim($result[3]).'" '.$select.'>'.trim($result[4]).'-'.trim($result[1]).'-'.trim($result[2]).'-'.trim($result[3]).'</option>';
         }   
  }
        return $data;
 }
 
 
 
function  GetSubstituteLaptop($id)
 {
	 $sql = mysql_query('Select usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.serial_no,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no FROM users as usr INNER JOIN laptop as lpt ON usr.user_id = lpt.user_id INNER JOIN laptop_details as lpd ON lpd.laptop_id=lpt.laptop_id where usr.user_no="'.trim($id).'" and lpt.dispatch="1" and lpt.returned="0" AND lpd.laptop_type="S"');

if(mysql_num_rows($sql)>0)
{
		$data .='<table border="0" class="grid" width="1050" cellpadding="4"><tr>
								<th><b>Employee Number</b></th>
								<th><b>Employee Name</b></th>
								<th><b>Division</b></th>
								<th><b>Model No</b></th>
								<th><b>Serial No.</b></th>						
								<th><b>Region</b></th>
								<th><b>Dispatch From Location</b></th>
								<th><b>Dispatch To Location</b></th>
								<th><b>Dispatch Date</b></th>
								<th><b>Marks</b></th>
								<th><b>Select Type</b></th>
								</tr>';
while($result = mysql_fetch_array($sql))
	    {

				$data .= '<tr class="odd">
										<td align="center">'.$result['user_no'].'</td>
										<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
										<td align="center">'.$result['division'].'</td>
										<td align="center">'.$result['laptopmodel'].'</td>
										<td align="center">'.$result['serial_no'].'</td>						
										<td align="center">'.$result['region'].'</td>
										<td align="center">'.$result['depot_location'].'</td>
										<td align="center">'.$result['dispatch_location'].'</td>					
										<td align="center">'.$result['dispatch_date'].'</td>
										<td align="center"><textarea name="laptopremarkss" id="laptopremarkss" rows="1" cols="15"></textarea></td>
										<td align="center">
				<input type="hidden" value="'.$result['laptop_id'].'" name="laptop_ids">
				<input type="hidden" value="'.$result['laptopmodel'].'" name="laptop_models">
				<input type="hidden" value="'.$result['serial_no'].'" name="serial_nos">
				<input type="hidden" value="'.$result['dispatch_location'].'" name="dispatch_locations">
				
				<select name="typeslap" id="typeslap">
                  <option value="Return" selected="selected">Return</option>
                  <option value="retainted">Taken Home</option>
                  <option value="Lost">Lost/Stolen</option>
                  <option value="Damaged">Damaged</option>
                </select>
				</td></tr>';
        }
        $data .= '</table>';
}
else
{
    $data ='<table border="0" class="grid" width="1000"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
   return $data;
}

function GetReceivedSublapTechGrid($id)
{
  $sql=mysql_query('SELECT usr.user_no,usr.user_firstname,usr.user_lastname,lpt.division,lpt.laptopmodel,lpt.serial_no,lpt.region,lpt.depot_location,lpt.dispatch_location,lpt.dispatch_date,lpt.laptop_id,lpt.serial_no FROM users as usr INNER JOIN  laptop as lpt INNER JOIN substitute_laptop as rl ON  usr.user_id = lpt.user_id and lpt.laptop_id = rl.laptop_id where usr.user_no="'.trim($id).'" and rl.received ="0" and rl.status = "Return"');
  
  if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Received</b></th>
						<th></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">';
					$data .='<input type="hidden" name="laptops_id" value="'.$result['laptop_id'].'">
<input type="checkbox" name="typesub" id="typesub" value="'.$result['laptop_id'].'">';
						
						
$data .='</td>
</tr>';
						}
$data .= '</table>';
}
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data;
}

function GetReturnSubTechGrid($id)
{
  $sql = mysql_query('SELECT DISTINCT usr.user_no, usr.user_firstname, usr.user_lastname, lpt.laptopmodel, lpt.dispatch_location, lpt.dispatch_date, lpt.laptop_id,lpt.serial_no
FROM users AS usr INNER JOIN laptop AS lpt INNER JOIN substitute_laptop AS rl ON usr.user_id = lpt.user_id AND lpt.laptop_id = rl.laptop_id
WHERE usr.user_no="'.trim($id).'" and rl.status = "Return" and rl.received="1" ORDER BY usr.user_no ASC');


if(mysql_num_rows($sql)>0)
{
$data .='<table border="0" class="grid" width="980"><tr>
						<th><b>Employee Number</b></th>
						<th><b>Employee Name</b></th>
						<th><b>Model No</b></th>
						<th><b>Serial No</b></th>
						<th><b>Dispatch Location</b></th>
						<th><b>Dispatch Date</b></th>					
						<th><b>Status</b></th>
						<th></th>					
						</tr>';
while($result = mysql_fetch_array($sql)){

$data .= '<tr class="odd">
						<td align="center">'.$result['user_no'].'</td>
						<td align="center">'.$result['user_firstname'].'&nbsp;'.$result['user_lastname'].'</td>
						<td align="center">'.$result['laptopmodel'].'</td>
						<td align="center">'.$result['serial_no'].'</td>
						<td align="center">'.$result['dispatch_location'].'</td>					
						<td align="center">'.$result['dispatch_date'].'</td>
						<td align="center">
						<input type="hidden" name="laptops_id" id="laptops_id" value="'.$result['laptop_id'].'">
						<input type="hidden" name="serials_no" id="serials_no" value="'.$result['serial_no'].'"><select name="typesub" id="typesub">
<option value="Available" selected="selected">Available - free</option>
<option value="Onhold">Available-on hold</option>
<option value="DamagedU">Damaged - Repair under warranty</option>
<option value="DamagedO">Damaged - repair out of warranty</option>
</select>
</td>
</tr>';
   }
$data .= '</table>';
 }
else
{
$data ='<table border="0" class="grid" width="980"><tr><td><strong>No Records Found</strong></td></tr></table><b>';
}
return $data; 
}

function GetDepotLocation1()
{
  $sql = mysql_query('SELECT user_address FROM users where user_groups_id="4" order by user_address ASC');
  $data .='<select name="depot_location" id="depot_location" >';
  $data .='<option value="0" selected="selected">Select</option>';

    while($result = mysql_fetch_row($sql))
     {
       if($result[0])
         {
           $select = 'selected="selected"';
         }
      else
       {
         $select = '';
       }

       $data .='<option value="'.$result[0].'" '.$select.'>'.$result[0].'</option>';
    }
    $data .='</select>';
    return $data;
}
?>